#include "getopt.h"
#include "application.h"
#include <qtsingleapplication.h>

//#include <QxtLogger>

Application* oApp;

int main(int argc, char **argv)
{
    Application app(argc, argv);    
    //QxtLogger::getInstance()->info("Start");

    QtSingleApplication instance("Optra System Manager", argc, argv);
    QCoreApplication::setOrganizationName("Optra Acme");
    QCoreApplication::setOrganizationDomain("Optra.org");
    QCoreApplication::setApplicationName("Optra System");

    QStringList args = instance.arguments();

    oApp = &app;
    app.initialize();

    if (instance.sendMessage(args.join(" "))){
        return 0;
    }



    instance.installEventFilter(&app);


    QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
                         &app, SLOT(handleMessage(const QString&)));

    instance.setActivationWindow(app.primaryScene()->views().at(0), false);



    return instance.exec();
}
